<template>
  <div class="list">
    <h3><span>大家再说</span></h3>
    <ul class="listCon">
      <transition-group
        tag="ul"
        name="fade"
        enter-active-class="animated fadeOut"
        leave-active-class="animated fadeOut"
      >
        <li v-for="(item, index) in arr" :key="index">
          <div class="float"><img :src="item.src" alt="" /></div>
          <div class="float right">
            <div>
              <a href="#">{{ item.name }}</a>
              <span class="cont">: {{ item.content }}</span>
            </div>
            <div class="times">
              <span class="time">{{ item.time }}</span>
              <a href="#" class="del" @click.prevent="delItem(index)">删除</a>
            </div>
          </div>
        </li>
      </transition-group>
    </ul>
  </div>
</template>

<script>
export default {
  props: {
    arr: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    delItem(index) {
      this.$emit('del', index)
    },
  },
}
</script>

<style lang="scss">
@import url('./animate.css@3.5.1.css');
* {
  padding: 0;
  margin: 0;
}
a {
  text-decoration: none;
}
ul {
  list-style: none;
  padding: 15px;
  margin: 0;
  padding-top: 0;
}
.list {
  width: 480px;
  height: 340px;
  padding: 10px;
  h3 {
    height: 33px;
    font-size: 14px;
    font-weight: 400;
    background: #e3eaec;
    position: relative;
    span {
      background: #fff;
      line-height: 28px;
      display: inline-block;
      padding: 0 15px;
      position: absolute;
      bottom: 0;
      left: 15px;
    }
  }
}
.listCon {
  img {
    width: 50px;
    height: 50px;
    margin-right: 10px;
  }
  li {
    overflow: hidden;
    font-size: 14px;
    width: 450px;
    border-bottom: 1px dashed #d8d8d8;
    padding: 10px 0;
    &:hover {
      background: #f5f5f5;
      .del {
        display: inline-block;
      }
    }
    a {
      color: #2b4a78;
    }
  }
}
.times {
  margin-top: 10px;
  font-size: 12px;
  .del {
    float: right;
    display: none;
  }
}
.float {
  float: left;
}
.right {
  width: 380px;
}
</style>
